package com.gohome.gohomechat.presenter;

import com.gohome.gohomechat.model.AddressModel;
import com.gohome.gohomechat.model.entify.Friend;
import com.gohome.gohomechat.model.modellistener.AddressModelInterface;
import com.gohome.gohomechat.presenter.callback.AddressCallBack;
import com.gohome.gohomechat.presenter.presenterlistener.AddressPresenterInterface;
import com.gohome.gohomechat.ui.viewlistener.AddressViewInterface;

import java.util.List;

/**
 * Created by dllo on 16/3/1.
 */
public class AddressPresenter extends BasePresenter<AddressViewInterface> implements AddressPresenterInterface {
    private AddressViewInterface addressViewInterface;
    private AddressModelInterface addressModelInterface;

    public AddressPresenter(AddressViewInterface addressViewInterface) {
        this.addressViewInterface = addressViewInterface;
        this.addressModelInterface = new AddressModel();
    }

    @Override
    public void requestData() {
        obtainDataResult();
    }

    @Override
    public void updateData() {
        obtainDataResult();
    }

    @Override
    public void toNoticeActivity() {
        addressViewInterface.toNoticeActivitySuccess();
    }

//    @Override
//    public void newNoticeToNoticeActivity(String userName, String reason) {
//        addressViewInterface.newNoticeToNoticeActivity(userName,reason);
//    }


    private void obtainDataResult() {
        addressModelInterface.requestData(new AddressCallBack() {
            @Override
            public void onScuess(List<Friend> datas) {
                addressViewInterface.updateData(datas);
            }

            @Override
            public void onFailed() {
                addressViewInterface.obtainDataFailed();
            }
        });
    }
}
